package com.vcredit.creditcat.web.app;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.vcredit.creditcat.api.IMyIncomeManager;
import com.vcredit.creditcat.dto.income.MyIncomeDto;
import com.vcredit.creditcat.model.Cust;
import com.vcredit.creditcat.vo.JsonResult;
import com.vcredit.creditcat.vo.MyIncomeResultVo;
import com.vcredit.framework.annotation.Log;

/**
 * @description: ${todo} (描述这个文件的作用) Project Name:credit_cat File
 *               Name:MyIncomeController.java Copyright (c) 2017/8/10 @author:
 *               张新功 Inc.All Rights Reserved.
 */
@RestController
public class MyIncomeController extends BaseCreditCatController {

	@Reference(version = "1.0")
	private IMyIncomeManager myIncomeManager;

	@RequestMapping("/user/income")
	@Log
	public JsonResult<MyIncomeResultVo> myIncomeList(HttpServletRequest request) {
		Cust cust = super.getCust(request);
		MyIncomeResultVo resultVo = new MyIncomeResultVo();
		List<MyIncomeDto> list = myIncomeManager.listIncome(cust.getCustId());
		resultVo.setProfitItems(list);
		return JsonResult.SuccessResponse(resultVo);
	}

	@RequestMapping("/user/income/draw")
	@Log
	public JsonResult drawIncome(@RequestBody Map<String,String> param,HttpServletRequest request) throws Exception {
		myIncomeManager.drawIncome(Long.parseLong(param.get("incomeLogId")), super.getCust(request).getCustId());
		return new JsonResult(null);
	}
}
